import pandas as pd
import numpy as np
import lightgbm as lgb
import random

x_train = pd.DataFrame()
x_train['id']=[0,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20]
x_train['id1']=[0,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20]
# x_train['id2']=[0,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20]
# x_train['id3']=[0,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20]
# x_train['id4']=[0,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20]
# x_train['id5']=[0,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20]
# x_train['id6']=[0,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20]
# x_train['id7']=[0,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20]
# x_train['id8']=[0,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20]
# x_train['id9']=[0,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20]
# x_train['id10']=[0,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20]
train_y=[0,1,2,3,4,0,1,2,3,4,0,1,2,3,4,0,1,2,3,4]
d_train = lgb.Dataset(x_train, label=train_y)

params = {}
params['max_bin'] = 255
params['learning_rate'] = 0.2  
params['boosting_type'] = 'gbdt'
params['objective'] = 'multiclass'
params['metric'] = 'multi_logloss'
params['num_class'] = 8900
params['num_iterations'] = 100
params['num_leaves'] = 5 
params['verbose'] = 0

np.random.seed(0)
random.seed(0)

print("Fitting LightGBM model ...")
clf = lgb.train(params, d_train, 10)

print("Prepare for LightGBM prediction ...")
x_test = pd.DataFrame()
x_test['id']=[0,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20]
x_test['id1']=[0,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20]
# x_test['id2']=[0,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20]
# x_test['id3']=[0,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20]
# x_test['id4']=[0,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20]
# x_test['id5']=[0,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20]
# x_test['id6']=[0,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20]
# x_test['id7']=[0,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20]
# x_test['id8']=[0,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20]
# x_test['id9']=[0,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20]
# x_test['id10']=[0,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20]
print("Start LightGBM prediction ...")
p_test = clf.predict(x_test)
print(p_test)
a = pd.DataFrame()
a['key'] = [0,1,2,3,4,5]
b = pd.DataFrame()
b['key'] = [0,1,2,3,4,5,6,7,8,9]
b['value'] = [0,1,2,3,4,5,6,7,8,9]
a = a.merge(b, how='left', on='key')
print(a)